import { Message } from "@arco-design/web-vue";
import { request } from "../utils/request";

export const apis = {
  save: "/ques/save",
  list: "/ques/list",
  findByType: "/ques/:type",
  del: "/ques/:id",
  findById: "/ques/findById/:id",
};

export const saveQuestion = async (data) => {
  const res = await request("插入或更新题目", {
    url: apis.save,
    method: "post",
    data: data,
  });
  if (res.success) {
    Message.success("插入成功");
  }
  return res;
};
export const findQuestions = async () => {
  const res = await request("查询题目列表", {
    url: apis.list,
    method: "get",
  });
  return res;
};

export const findByTypeQuestions = async (params) => {
  const res = await request("查询题目列表", {
    url: apis.findByType,
    method: "get",
    params,
  });
  return res;
};
export const delQuestion = async (params) => {
  const res = await request("删除题目", {
    url: apis.del,
    method: "delete",
    params: params,
  });
  if (res.success) {
    Message.success("删除成功");
  }
  return res;
};

export const getQuestionById = async (params) => {
  const res = await request("根据id查询", {
    url: apis.findById,
    method: "get",
    params: params,
  });
  return res;
};
